package logic

import (
	"context"
	"store/models/mysql"

	"store/storerpc/internal/svc"
	"store/storerpc/storerpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type StorerpcAddLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewStorerpcAddLogic(ctx context.Context, svcCtx *svc.ServiceContext) *StorerpcAddLogic {
	return &StorerpcAddLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *StorerpcAddLogic) StorerpcAdd(in *storerpc.StorerpcAddRequest) (*storerpc.StorerpcAddResponse, error) {
	// todo: add your logic here and delete this line
	var a = mysql.Merchants{
		Name:  in.Name,
		Types: in.Types,
	}
	mysql.DB.Debug().Create(&a)
	return &storerpc.StorerpcAddResponse{
		Id: int64(a.ID),
	}, nil
}
